"""
继承和多态
 Java中的继承是 单继承
 Python中的继承是 多继承
"""
#定义Person类 作为父类
class Person():

    def __init__(self,name,age):
        self._name = name
        self._age = age
    @property
    def name(self):
        return self._name
    @name.setter
    def name(self,name):
        self._name = name
    @property
    def age(self):
        return self._age
    @age.setter
    def age(self,age):
        self._age = age

    def eatFood(self):
        print('%s正在吃东西' % self._name)

    def watchMovie(self):
        if self.age < 18:
            print('%s只能看《熊出没》' % self._name)
        else:
            print('%s正在看Python100天基础大全' % self._name)


class Student(Person):
    #父类拥有的属性 子类必然会继承，在初始化的时候只需要调用父类的初始化即可
    def __init__(self,name,age,grade):
        super().__init__(name,age)
        self.__grade = grade
    @property
    def grade(self):
        return self.__grade
    @grade.setter
    def grade(self,grade):
        self.__grade = grade
    #子类也会继承父类的方法
    def study(self,courseName):
        print("%s正在学习%s,年级：%s" % (self._name,courseName,self.__grade))
        #super().eatFood()

    def eatFood(self):
        print('学生再吃东西')

if __name__ == '__main__':
     # __ 私有   _受保护
    stu =Student("王大锤",16,'初三')
    stu.study("物理")
    stu.eatFood()
    stu.watchMovie()